'''
Created on Apr 16, 2012
TC ID: Ecom_5018
Desc: Kiem thu  chuc nang xoa loai tai khoan
@author: lavang
'''
import unittest
from Functions.globalFunc import preCondition, readData, endCondition
from Functions.loginPageFunc import login
from Functions.userTypesFunc import clickOnUserTypes, deleteUserType,\
    isUserTypeDeleted
from HTMLTestRunner import HTMLTestRunner
import time

username=readData("username")
password=readData("password")
tm_typeName=readData("userTypeName",index=2)
class Ecom_5018(unittest.TestCase):


    def setUp(self):
        preCondition(self)

    def test_Ecom_5018(self):
        print "Buoc 1: Dang nhap vao website"
        login(self,username,password)

        print "Buoc 2: Click vao User Type"
        clickOnUserTypes(self)
        
        print "Buoc 3: Xoa mot loai User Type co trong danh sach"
        deleteUserType(self,tm_typeName)
        
        print "Buoc 4: Xac nhan xoa User Type thanh cong"
        self.assertFalse(isUserTypeDeleted(self,tm_typeName), "Failed!")
        print "Xoa User Type thanh cong"
    def tearDown(self):
        endCondition(self)



if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5018)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang xoa mot User Type'
                    )
    runner.run(suite)